<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="../include/tag.jsp"%>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>数据查看</title>
    <%@include file="../include/commonFile.jsp"%>
    <link rel="stylesheet" href="${ctx}/css/common/list.css">
    <link rel="stylesheet" href="${ctx}/css/common/table.css">

</head><body>
<%@include file="../include/header.jsp"%>

<div class="index-outside">
    <%@include file="../include/sidebar.jsp"%>
    <section>
        <div class="section-main">
            <%--联合发起--%>
            <div class="layui-tab layui-tab-brief mt20">
                <ul class="layui-tab-title">
                    <c:choose>
                        <c:when test="${isMultiple == true}">
                            <li >众筹<span class="pl5">${activity.joinNum}</span>人</li>
                            <li class="layui-this">联合发起<span class="pl5">${activity.representNum}</span>人</li>
                        </c:when>
                        <c:otherwise>
                            <li>众筹<span class="pl5">${activity.joinNum - directPayNum}</span>人</li>
                            <li class="layui-this">联合发起<span class="pl5">${activity.representNum}</span>人</li>
                            <li>直接付款<span class="pl5">${directPayNum}</span>人</li>
                            <li>转入<span class="pl5">${transferNum}</span>人</li>
                        </c:otherwise>
                    </c:choose>
                </ul>
                <div class="layui-tab-content">
                    <div class="layui-tab-item  layui-show">
                        <form class="layui-form" action="${ctx}/activity/activity/zcRepresentList.do?id=${activity.id}" id="myForm" method="post">
                            <input type="hidden" name="pageNo" id="pageNo" />
                            <div class="f-search-bar">
                                <div class="search-container">
                                    <ul class="search-form-content">
                                        <li class="form-item-inline"><label class="search-form-lable">姓名：</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="authorName" autocomplete="off" class="layui-input" value="${withCount.authorName}"
                                                       placeholder="姓名"
                                                >
                                            </div></li>
                                        <li class="form-item-inline"><label class="search-form-lable">联系电话：</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="authorMobile" autocomplete="off" class="layui-input" value="${withCount.authorMobile}"
                                                       placeholder="联系电话"
                                                >
                                            </div>
                                        </li>
                                        <li class="form-item-inline">
                                            <div class="sub-btns">
                                                <a class="layui-btn layui-btn-danger" href="javascript:submitFunction('#myForm')">查询</a>
                                                <a class="layui-btn layui-btn-normal" href="javascript:resetFunction('#myForm')">重置</a>
                                            </div>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                        </form>
                        <div class="my-act-list-content">
                            <ul class="num">
                                <div class="l">
                                    <li class="f16">联合发起<span class="red">${page.totalCount}</span>人</li>
                                </div>
                                <div class="r">
                                    <li style="cursor: pointer;" class="r">
                                        <c:if test="${empty zipUrl}">
                                            <a class="layui-btn layui-btn-danger layui-btn-sm" href="javascript:txz.expireCheck('', function() { exportExcelData() })">导出EXCEL</a>
                                        </c:if>
                                        <c:if test="${not empty zipUrl}">
                                            <a class="layui-btn layui-btn-danger layui-btn-sm" href="javascript:txz.expireCheck('', function() { exportExcelData() })">重新生成EXCEL</a>
                                            <c:if test="${not empty zipUploadTime}">
                                                <a class="layui-btn layui-btn-danger layui-btn-sm" target="_blank" href="${zipUrl}"
                                                   title="上次生成时间：${zipUploadTime}" >点击下载</a>
                                            </c:if>
                                            <c:if test="${empty zipUploadTime}">
                                                <a class="layui-btn layui-btn-danger layui-btn-sm" target="_blank" href="${zipUrl}">点击下载</a>
                                            </c:if>
                                        </c:if>
                                    </li>
                                </div>
                                <p class="cl"></p>
                            </ul>
                            <div class="cl">
                                <table class="layui-table">
                                    <colgroup>
                                        <col>
                                        <col>
                                        <col>
                                        <col>
                                        <col width="130px">
                                        <col width="100px">
                                        <col width="100px">
                                        <col width="130px">
                                        <col width="100px">
                                        <col width="100px">
                                    </colgroup>
                                    <thead>
                                    <tr>
                                        <th>姓名</th>
                                        <th>公司</th>
                                        <th>区域</th>
                                        <th>职务</th>
                                        <th>联系电话</th>
                                        <th>众筹人数</th>
                                        <th>支持人数</th>
                                        <th>支持金额</th>
                                        <th>浏览量</th>
                                        <th>分享量</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <c:forEach var="directPay" items="${list}">
                                        <tr>
                                            <td class="table-member" onclick="openDialogShow('用户名片','${ctx}/system/member/memberView.do?id=${directPay.distributorId}','400px','470px')">
                                                <div class="member-cell">
                                                <div class="member-logo common-img">
                                                    <img src="<c:if test="${ directPay.authorLogo!= null}">${directPay.authorLogo}?imageMogr2/auto-orient/crop/126x126</c:if>" alt="" onerror="txz.errImg(this)" onload="txz.imgLoad(this)">
                                                </div>
                                                <div class="member-name ellipsis-1"><a class="blue" title="${directPay.authorName}" href="javascript:void(0);" >${directPay.authorName}</a></div>
                                                </div>
                                            </td>
                                            <td>
                                                <div class="ellipsis-1" title="${directPay.authorCompany}">${directPay.authorCompany}</div>
                                            </td>
                                            <td>
                                                    ${directPay.cityName}
                                            </td>
                                            <td>
                                                    ${directPay.authorJobTitle}
                                            </td>
                                            <td>
                                                    ${directPay.authorMobile}
                                            </td>
                                            <td>
                                                <a href="javascript:void(0);" class="blue ${directPay.crowdfundNum > 0 ? 'crowdfundNum' : ''} count-num" data-id="${directPay.id}" data-name="${directPay.authorName}">${directPay.crowdfundNum}</a>

                                            </td>
                                            <td>
                                                <a href="javascript:void(0);" class="blue ${directPay.actualAmount > 0 ? 'favorerNum' : ''} count-num" data-id="${directPay.id}" data-name="${directPay.authorName}">${directPay.favorerNum}</a>

                                            </td>
                                            <td>
                                                <a href="javascript:void(0);" class="blue ${directPay.actualAmount > 0 ? 'actualAmount' : ''} count-num" data-id="${directPay.id}" data-name="${directPay.authorName}"> ${directPay.actualAmount}</a>

                                            </td>
                                            <td>
                                                    ${directPay.viewNum}
                                            </td>
                                            <td>
                                                    ${directPay.shareNum}
                                            </td>
                                            <td>
                                                <a class="qr-btn"
                                                   href="javascript:txz.openQrDialog({
                                                               title:'扫码二维码可预览分享',
                                                               detailList:[
                                                                   {
                                                                   title:'联合发起',
                                                                   url:'${directPay.qrCodeUrl }',
                                                                   link:'${directPay.url}'
                                                                   }
                                                               ]
                                                               })">二维码</a>
                                                <c:if test="${empty directPay.crowdfundNum or directPay.crowdfundNum == 0}">
                                                    <a href="javascript:txz.deleteObject('确定要删除该联合发起众筹吗？', '${ctx}/crowdfund/project/deleteRepresent.do?id=${directPay.id}');"
                                                       target="_self">
                                                        删除
                                                    </a>
                                                </c:if>
                                            </td>
                                        </tr>
                                    </c:forEach>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div id="page_content" class="page-container"></div>
                    </div>
                    <div class="layui-tab-item">

                    </div>
                </div>
            </div>
        </div><%@include file="../include/footer.jsp"%>
    </section>
</div>

<script type="text/javascript" src="${ctx}/script/common/list.js"></script>
<script type="text/javascript">
    txz.initHeader({
        nav: [{
            name: '众筹项目',
            href: '${ctx}/activity/activity/zcActivityList.do'
        }, {
            name: '${activity.title}'
        }, {
            name: '数据查看',
            curr: true
        }],
        btns: [{
            type: 'back'
        }]
    });

    $(function () {

        //加载分页
        loadPageNew({
            elem: 'page_content',
            totalCount: '${page.totalCount}',
            limit: '${page.limit}',
            page: '${page.page}'
        });

        if (${isMultiple == true}) {
            $("#myForm").attr('action', '${ctx}/activityMultiple/represent/listForActivity.do?id=${activity.id}');
        }

        layui.use(['element'], function () {
            var element = layui.element;

            element.on('tab', function (data) {
                if (${isMultiple == true}) {
                    if (data.index == 0) {
                        window.location.href = "${ctx}/activityMultiple/project/listForActivity.do?id=${activity.id}";
                    } else if (data.index == 1) {
                        window.location.href = "${ctx}/activityMultiple/represent/listForActivity.do?id=${activity.id}";
                    }
                } else {
                    if (data.index == 0) {
                        window.location.href = "${ctx}/activity/activity/zcCrowdfundList.do?id=${activity.id}";
                    } else if (data.index == 1) {
                        window.location.href = "${ctx}/activity/activity/zcRepresentList.do?id=${activity.id}";
                    } else if (data.index == 2) {
                        window.location.href = "${ctx}/activity/activity/zcDirectPayList.do?id=${activity.id}";
                    } else if (data.index == 3) {
                        window.location.href = "${ctx}/activity/activity/zcShiftToPeopleList.do?id=${activity.id}";
                    }
                }
            });
        });
        $('.crowdfundNum').click(function () {
            var relationId = this.dataset.id;
            if (${isMultiple == true}) {
                window.location.href = '${ctx}/activityMultiple/project/activity/listForDistributor.do?relationId=' + relationId;
            } else {
                window.location.href = '${ctx}/crowdfund/project/listForDistributorId.do?id=${activity.id}&relationId=' + relationId;
            }
        });


        $('.favorerNum').click(function () {
            var relationId = this.dataset.id;
            if (${isMultiple == true}) {
                window.location.href = '${ctx}/activityMultiple/support/activity/listForDistributor.do?id=${activity.id}&relationId=' + relationId;
            } else {
                window.location.href = '${ctx}/crowdfund/support/listForDistributorId.do?id=${activity.id}&relationId=' + relationId;
            }
        });

        $('.actualAmount').click(function () {
            var relationId = this.dataset.id;
            if (${isMultiple == true}) {
                window.location.href = '${ctx}/activityMultiple/support/activity/listForDistributor.do?id=${activity.id}&relationId=' + relationId;
            } else {
                window.location.href = '${ctx}/crowdfund/support/listForDistributorId.do?id=${activity.id}&relationId=' + relationId;
            }
        });
    })

    function exportExcelData() {
        layer.confirm('确认要导出Excel吗?', {
            icon: 3,
            title: '系统提示'
        }, function (index) {
            //loading层
            var loadIndex = layer.load(1, {
                shade: [0.1, '#fff'] //0.1透明度的白色背景
            });
            $.post("${ctx}/activity/activity/representListExport.do?id=${activity.id}", $("#myForm").serialize(), function (data) {
                console.log('start : ' + new Date().getTime());
                layer.close(loadIndex);
                if (data.success) {
                    util.layerAlertSuccess("正在导出中请耐心等待，稍后请点击下载按钮即可下载文件。")
                } else {
                    util.layerAlertError("操作失败");
                }
            });
            top.layer.close(index);
        });
    }

    util.initWebSocket(function (event) {
        console.log(event.data);
        console.log('end : ' + new Date().getTime());
        if (event.data) {
            util.layerAlertSuccess(event.data, function () {
                var title = "\"${activity.title}\"";
                var substr = event.data.substring(0, event.data.indexOf('联合发起人员导出成功了'));
                if (title == substr) {
                    location.reload();
                }
            })
        }
    });
</script>
</body>
</html>
